package com.Maykk.Demo07;

/**
 * @ClassName: StudentBuilderTest
 * @Description: TODO
 * @Author: MaykkStar@163.com
 */
public class StudentBuilderTest {
    public static void main(String[] args) {
        // 匿名内部类
        runStuBuilder(new StudentBuilder() {
            @Override
            public Student build(String name, int age) {
                return new Student(name, age);
            }
        });

        // 完整 Lambda
        runStuBuilder((String name, int age) -> {
            return new Student(name, age);
        });

        // 省略 Lambda
        runStuBuilder((name, age) -> new Student(name, age));
        // 引用构造器
        runStuBuilder(Student:: new);

    }

    public static void runStuBuilder(StudentBuilder sb) {
        Student stu = sb.build("Maykk", 19);
        System.out.println(stu);
    }
}
